<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns:jsf="http://xmlns.jcp.org/jsf"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns="http://www.w3.org/1999/xhtml"> 
        <h:form > 
            <input type="submit" class="button" value="Novo" 
                   jsf:action="${artistManagedBean.openNew}" jsf:id="novo"/>
            <br/><br/>
            <fieldset>
                <legend>Consulta de Artistas</legend>
                <div class="messagesContainer"><h:messages warnClass="warnMessages" class="messages"/></div>
                <f:view>
                    <h:panelGroup rendered="${not empty artistManagedBean.list}">
                        <table class="tableConsulta">
                            <thead>
                                <tr>
                                    <td>
                                        Nome Artístico
                                    </td>                               
                                    <td>
                                        Origem
                                    </td>
                                    <td>
                                       Ano de criação
                                    </td>  
                                    <td>
                                       Gênero
                                    </td>  
                                    <td>
                                        Editar
                                    </td>                        
                                    <td>
                                        Excluir 
                                    </td>         
                                </tr>
                            </thead>
                            <tbody>                        
                                <ui:repeat value="${artistManagedBean.list}" var="artist">
                                    <tr>
                                        <td>
                                            ${artist.name}
                                        </td>                                 
                                        <td>
                                            ${artist.originCity.name}
                                        </td>
                                        <td>
                                            ${artist.year}
                                        </td>
                                        <td>
                                            ${artist.genre.name}
                                        </td>
                                        <td>
                                            <input type="submit" class="buttonEdit" value="" jsf:action="${artistManagedBean.openToUpdate}" jsf:id="editar">
                                                <f:param value="${artist.id}" name="id"/>
                                            </input>
                                        </td>
                                        <td>
                                            <input type="submit" class="buttonDelete" value="" jsf:action="${artistManagedBean.delete}" jsf:id="deletar">
                                                <f:param value="${artist.id}" name="id"/>
                                            </input>
                                        </td>
                                    </tr>                       
                                </ui:repeat>
                            </tbody>
                        </table>
                    </h:panelGroup>
                    <h:panelGroup rendered="${empty artistManagedBean.list}">
                        <br/>Ainda não há artista cadastradas.
                    </h:panelGroup>

                </f:view>
            </fieldset>    
        </h:form>
    
</html>

